using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;

using DailyReport.Core.Bussines;
using DailyReport.Core.Bussines.IManagers;
using DailyReport.Core.Data.Dao;
using DailyReport.Core.Data.Dao.DaoFactory;
using DailyReport.Core.Data.Model;
using DailyReport.Core.Util;
using DailyReport.NHibernateDao.Data.Dao;
using log4net;
using NHibernate;

public partial class Pages_Teams_ListTeam : System.Web.UI.Page
{
    private List<Button> btnUpDateTeams = new List<Button>();
    

    protected void Page_Load(object sender, EventArgs e)
    {
        ISession session = ConnectionManager.Instance.Session;
        List<TableRow> rows= new List<TableRow>();

        /*TeamManager tm = new TeamManager();        
        lblTitle.Text += tm.CountInstances();
        lblTitle.Text += tm.GetInstanceList("Name", 0, 10).Count;
        */

        TeamDao teamDao = new TeamDao();
        teamDao.Session = session;
        foreach (Team team in teamDao.GetAll())
        {
            try
            {
                //lblTitle.Text += team.ID + ";";

                /*Button btnUpDateTeam = new Button();
                btnUpDateTeam.Text = "UpDate Team";
                btnUpDateTeam.PostBackUrl="~/Pages/Teams/UpdateTeam.aspx";                
                */
                LinkButton btnUpDateTeam = new LinkButton();
                btnUpDateTeam.Text = "UpDate Team";
                btnUpDateTeam.PostBackUrl = "~/Pages/Teams/UpdateTeam.aspx";


                TableCell celName = new TableCell();
                celName.Text = team.Name;
                //celName.SkinID = "ASPCell";

                TableCell cellManager = new TableCell();
                cellManager.Width = 250;
                //cellManager.SkinID = "ASPCell";
                cellManager.Text = team.Manager.FirstName + " " + team.Manager.LastName;

                TableCell cellParent = new TableCell();
                cellParent.Text = team.ParentTeam.Name;
                //cellParent.SkinID = "ASPCell";

                TableCell cellOption = new TableCell();
                cellOption.Controls.Add(btnUpDateTeam);

                TableRow row = new TableRow();
                row.SkinID = "ASPRow";
                row.Cells.Add(celName);
                row.Cells.Add(cellManager);
                row.Cells.Add(cellParent);
                row.Cells.Add(cellOption);
                row.Height = 40;
                row.BorderColor = Color.Black;                
                tableList.Rows.Add(row);
            }
            catch (Exception ex)
            {
            }
        }
    }
    protected void btnCreateTeam_Click(object sender, EventArgs e)
    {
        Server.Transfer("~/Pages/Teams/CreateTeam.aspx");
    }

    protected void btnUpdateTeam_Click(object sender, EventArgs e)
    {
        Server.Transfer("~/Pages/Teams/UpdateTeam.aspx");
    }
}
